Feature: 找律师
  作为一个律团用户
  我可以找到合适的律师
  这样我就咨询更深入的法律问题

# 不成功的Scenarios

Scenario: 如果提交的律师的专长cat_id不是数字，系统会报错
 Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?cat_id=test"
  And the response is in "json" format
  Then the response status code should be 400
  And I got error message "cat_id需要是数字" for field "cat_id"

Scenario: 如果提交的律师的专长cat_id小于1，系统会报错
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?cat_id=0.2"
  And the response is in "json" format
  Then the response status code should be 400
  And I got error message "cat_id不能少于1" for field "cat_id"

Scenario: 如果提交的律师列表的页码page不是数字，系统会报错
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?page=happy"
  And the response is in "json" format
  Then the response status code should be 400
  And I got error message "page需要是数字" for field "page"

Scenario: 如果提交的律师列表的记录数rows_per_page不是数字，系统会报错
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?rows_per_page=happy"
  And the response is in "json" format
  Then the response status code should be 400
  And I got error message "rows_per_page需要是数字" for field "rows_per_page"

Scenario: 如果提交的律师列表的城市city_id不是数字，系统会报错
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?city_id=happy"
  And the response is in "json" format
  Then the response status code should be 400
  And I got error message "city_id需要是数字" for field "city_id"

Scenario: 如果提交的律师列表的城市district_id不是数字，系统会报错
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?district_id=happy"
  And the response is in "json" format
  Then the response status code should be 400
  And I got error message "district_id需要是数字" for field "district_id"

# 成功的Scenarios

Scenario: 可根据律师的专长来过滤律师
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?cat_id=2"
  And the response is in "json" format
  Then the response status code should be 200
 And I got message "cat_id=2" for field "query"
    
Scenario: 可以按照律师区域id的过滤律师列表
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?district_id=440304"
  And the response is in "json" format
  Then the response status code should be 200
  And I get message "福田区" for field "district"

Scenario: 可以按照律师城市id的过滤律师列表
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?city_id=440300"
  And the response is in "json" format
  Then the response status code should be 200
  And I get message "深圳市" for field "city"

Scenario: 可以得到被推荐的律师，is_recommended
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?is_recommended=1"
  And the response is in "json" format
  Then the response status code should be 200
  And I get message "1" for field "is_recommended"

Scenario: 可根据经验年限来过滤律师
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?experience=1to3"
  And the response is in "json" format
  Then the response status code should be 200
  And I get message "1-3年" for field "practice_period"

Scenario: 可以按照律师名字的关键字搜索
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?q=杨津津"
  And the response is in "json" format
  Then the response status code should be 200
  And I get message "杨津津" for field "realname"

Scenario: 可以得到按时间倒序排列的律师列表，order by created_at
# 比较数据的created_at的值，验证结果是按照这个值倒序排列
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?order_by=latest"
  And the response is in "json" format
  Then the response status code should be 200
  And the records are ordered by "created_at" in "DESC"

Scenario: 可以得到按人气最高排列的律师列表
# 比较数据的follows_count的值，验证结果是按照这个值倒序排列
Given a users "256" exists with:
  | follows_count | 
  |   123 |
  And a users "512" exists with:
    | follows_count | 
    |   122 |
  And a users "1280" exists with:
    | follows_count | 
    |   121 |
  And http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?order_by=most_popular&rows_per_page=30"
  And the response is in "json" format
  Then the response status code should be 200
  And the records are ordered by "follows_count" in "DESC"

Scenario: 可以得到按评价最好排列的律师列表
# 比较数据的average_evaluate_score的值，验证结果是按照这个值倒序排列
Given a lawyer "256" exists with:
  | average_evaluate_score | 
  |   123 |
  And a lawyer "512" exists with:
    | average_evaluate_score | 
    |   122 |
  And a lawyer "1280" exists with:
    | average_evaluate_score | 
    |   121 |
  And http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?order_by=best_evaluated"
  And the response is in "json" format
  Then the response status code should be 200
  And the records are ordered by "average_evaluate_score" in "DESC"

Scenario: 可以指定返回记录的起始位置，page, rows_per_page
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?rows_per_page=20"
  And I save no "18" lawyer in record
  And I am on "/lawyer/list_lawyers?rows_per_page=7&page=3"
  And the no "4" lawyer matches the record

Scenario: 可以指定返回多少条记录，rows_per_page
Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers?rows_per_page=3"
  And the response is in "json" format
  Then the response status code should be 200
  And there are "3" records

Scenario: 律师列表接口返回默认律师信息
 Given http "accept" header is "application/json"
  And I am on "/lawyer/list_lawyers"
  Then the response status code should be 200
  And the response is in "json" format
  And there are "10" records
  And each "lawyer" record contains: 
    | keys  | 
    | id |
    | avatar  | 
    | realname |
  And the records are ordered by "created_at" in "DESC"